<button class="btn btn-info" type="button" onclick="backinstore()">返回</button>
<form id="pomainForm" action="/addPomain">
    <table class="table">
        <tr>
            <td>采购单编号</td>
            <td><input type="text" id="poId" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>创建时间</td>
            <td><input type="text" id="createTime" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>供应商</td>
            <td><input type="text" id="venderName111" readonly><input hidden type="text" id="venderCode"><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span><img src="/img/编辑.png" style="width: 20px;height: 20px" onclick="selectVender(this)" /></td>
        </tr>
        <tr class="info">
            <td>创建用户</td>
            <td><input type="text" id="scmUserName" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>附加费用</td>
            <td><input type="text" id="tipFee" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>采购商品总价</td>
            <td><input type="text" id="productTotal" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
        </tr>
        <tr>
            <td>付款方式</td>
            <td><select id="payType" readonly>
                <option value="货到付款">货到付款</option>
                <option value="款到发货">款到发货</option>
                <option value="预付款发货">预付款发货</option>
            </select><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>最低预付款金额</td>
            <td><input type="text" id="prePayFee" readonly><span style="color:red;font-size: 20px;text-align: center;line-height: 28px">*</span></td>
            <td>备注</td>
            <td><input type="text" id="remark" readonly></td>
        </tr>
    </table>
    <table class="table" id="poitemtablelist">
        <thead>
        <tr>
            <th>序号</th>
            <th>产品编号</th>
            <th>产品名称</th>
            <th>数量单位</th>
            <th>产品数量</th>
            <th>产品体积</th>
            <th>采购单价</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="poitemtabletbody">

        </tbody>
    </table>
</form>
<script type="text/html" id="poitemtable">
    {{each data value index}}
    {{each value.productList plvalue plindex}}
    <tr>
        <td>{{index+1}}</td>
        <td><input type="text" name="productCode" value="{{plvalue.productCode}}"><img src="/img/编辑.png" style="width: 20px;height: 20px" onclick="selectProduct(this)" /></td>
        <td><input type="text" name="name" value="{{plvalue.name}}"></td>
        <td><input type="text" name="unitName" value="{{value.unitName}}"></td>
        <td><input type="text" name="num" value="{{value.num}}"></td>
        <td><input type="text" name=""></td>
        <td><input type="text" name="unitPrice" value="{{value.unitPrice}}"></td>
        <td><input type="button" value="删除" onclick="deleteItem(this)"></td>
    </tr>
    {{/each}}
    {{/each}}
</script>
<script>
    $(function () {
        Ajax.get(
            "selectByPoId",
            {poId:window.sessionStorage.getItem("poId")},
            function (result) {
                var div=document.getElementById("poitemtabletbody")
                var html=template('poitemtable',{data:result.data[0].poItemList})
                div.innerHTML=html
                $("#scmUserName").val(result.data[0].account)
                $("#poId").val(result.data[0].poId)
                $("#createTime").val(result.data[0].createTime)
                $("#tipFee").val(result.data[0].tipFee)
                $("#productTotal").val(result.data[0].productTotal)
                $("#payType").val(result.data[0].payType)
                $("#venderCode").val(result.data[0].venderCode)
                $("#prePayFee").val(result.data[0].prePayFee)
                $("#remark").val(result.data[0].remark)
                Ajax.get(
                    "selectByVenderCode",
                    {venderCode:result.data[0].venderCode},
                    function (result) {
                        $("#venderName111").val(result.data.name)
                    }
                )
            }
        )
    })
    function backinstore() {
        show("/store/inStore.html")
    }
</script>